ABS block

Short summary

Name

ABS

→POU type

→function

Category

IEC-block, Numericblock with internal error diagnostic

Conform to →IEC-standard

(tick) no restrictions

Graphical interface

Available since

  • version 1.17.0 (for Neuron Power Engineer) – initial variant

  • version 2.0.14 (for library Standard) – internal error diagnostic for block

  • version 3.1.0 (for library Standard) – For inputs of data type REAL, the optimized float variant of the C-runtime is used. Compared to previous versions, it is possible that (marginal) other results are returned within the threshold range of the block.

Functionality

The mathematical function Abs is called: The block returns the absolute value (i.e. without sign) of the value connected to the input value.

Special case: If the input gets a negative value that matches the lower limit of the data type, the block returns this negative value. Reason: There is no corresponding positive value for the lower limit (= the most negative value). Furthermore, the output ENO is set to value FALSE.
See under "Example for usage within ST-editor": If the most negative SINT value -128 is connected to the input, the blocks returns the value -128 (the most positive SINT value is 127) and ENO=FALSE.

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM)

value

Return value:

REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_NUM)

 

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Internal error diagnostic for block

The block checks the return value. If the return value is a negative value that matches the lower limit of the data type, the output ENO of the block is set to value FALSE (or an equivalent).

Example for usage within ST-editor

PROGRAM Test
   VAR
      result1, result2, result3 : SINT;
                                  CheckENO1, CheckE<NO2, CheckENO3 : BOOL;
                        
   END_VAR
   result1 := ABS(IN := -5, ENO => CheckENO1);      (* The variable 'result1' evaluates to '5'. The variable 'CheckENO1' evaluates to 'TRUE'. *)
   result2 := ABS(IN := -127, ENO => CheckENO2);    (* The variable 'result2' evaluates to '127'. The variable 'CheckENO2' evaluates to 'TRUE'. *)
   result3 := ABS(IN := -128, ENO => CheckENO3);    (* The variable 'result3' evaluates to '-128'. The variable 'CheckENO3' evaluates to 'FALSE'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.